package cn.tedu.health.service.impl;

import cn.tedu.health.mapper.RecommendationsMapper;
import cn.tedu.health.pojo.entity.Recommendations;
import cn.tedu.health.service.IRecommendationsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;

@Service
public class RecommendationsService implements IRecommendationsService {

    @Autowired
    private RecommendationsMapper recommendationsMapper;

    @Override
    public void createRecommendations(Recommendations recommendations) {
        recommendationsMapper.insert(recommendations);
    }

    @Override
    public Recommendations getRecommendations(Long userId, LocalDate date) {
        Map<String, Object> params = new HashMap<>();
        params.put("userId", userId);
        params.put("date", date);
        return recommendationsMapper.findByUserIdAndDate(params);
    }
}
